﻿using System;
using System.Data;

using Model.Data;
using DataAccess;
using BusinessLogic.BusinessRules;
using BusinessLogic.ClassFactory;

namespace BusinessLogic.BusinessRules
{
    /// <summary>
    /// LinksGroup 的摘要说明。
    /// </summary>
    public class LinksGroup : BaseClass
    {
        #region 必有属性
        public Model.Data.LinksGroupData.LinksGroupRow DataItem
        {
            get
            {
                return (Model.Data.LinksGroupData.LinksGroupRow)base.m_CurrentRow;
            }
            set
            {
                base.m_CurrentRow = value;
            }
        }

        private Model.Data.LinksGroupData m_Data
        {
            get
            {
                return (Model.Data.LinksGroupData)base.m_DataSet;
            }
            set
            {
                base.m_DataSet = value;
            }
        }


        public override int Count
        {
            get
            {
                return this.m_Data.LinksGroup.Count;
            }
        }
        #endregion

        #region 构造函数
        public LinksGroup(DataAccess.DBManager m_DBManager, DataAccess.BaseAccess m_Access)
            : base(m_DBManager, m_Access)
        {
        }
        #endregion

        #region 必须重载方法
        /// <summary>
        /// 根据数据集中索引,设置当前数据行
        /// </summary>
        /// <param name="n_index">数据集中的索引</param>
        public override void SelectRow(int n_index)
        {

            if (m_Data != null && m_Data.LinksGroup.Rows.Count > n_index)
            {
                DataItem = m_Data.LinksGroup[n_index];
            }
        }


        /// <summary>
        /// 实现更新
        /// </summary>
        /// <returns></returns>
        protected override int OnUpdate()
        {
            return m_Access.Update(this.m_DataSet);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        protected override bool OnDelete(int ID)
        {
            return true;
        }


        public override void NewDataSet()
        {

            this.m_Data = new LinksGroupData();
            m_CurrentRow = m_Data.LinksGroup.NewLinksGroupRow();
        }

        public override void SetDataSet(DataSet m_DataSet)
        {
            this.m_DataSet = m_DataSet;
        }

        public override bool OnInsert()
        {
            this.DataItem.intGroupID = this.GetNextSeed();
            this.m_Data.LinksGroup.Rows.Add(this.m_CurrentRow);
            return true;
        }
        #endregion

        #region 业务属性
        public Model.Data.LinksGroupData Data
        {
            get
            {
                return (Model.Data.LinksGroupData)base.m_DataSet;
            }
            set
            {
                base.m_DataSet = value;
            }
        }
        #endregion
    }
}
